<?php
class Servicemanager_Model_Insertnewservice implements Servicemanager_Model_Mainable{
    
    private $core_controller_notnull;
    private $core_controller_csrftoken;
    
    private $servicemanager_data_insertservicesettings;
    private $servicemanager_data_insertservicemetavalues;
    private $servicemanager_data_insertservicecontentvalues;
    
    private $insert_service_settings_result;
    private $insert_service_meta_values_result;
    private $insert_service_content_values_result;
    
    private $excepted_result;
    
    public function main(array $variables = null) {
        $this->core_controller_notnull = new Core_Controller_Notnull;
        $this->core_controller_notnull->main($variables);
        $this->core_controller_csrftoken = new Core_Controller_Csrftoken;
        $this->core_controller_csrftoken->main(['post']);
        
        $this->servicemanager_data_insertservicesettings = new Servicemanager_Data_Insertservicesettings;
        $this->servicemanager_data_insertservicemetavalues = new Servicemanager_Data_Insertservicemetavalues;
        $this->servicemanager_data_insertservicecontentvalues = new Servicemanager_Data_Insertservicecontentvalues;
        
        $this->insert_service_settings_result = $this->servicemanager_data_insertservicesettings->main($variables);
        $this->insert_service_meta_values_result = $this->servicemanager_data_insertservicemetavalues->main($variables);
        $this->insert_service_content_values_result = $this->servicemanager_data_insertservicecontentvalues->main($variables);
        
        if(
                ($this->insert_service_settings_result == $this->excepted_result) &&
                ($this->servicemanager_data_insertservicemetavalues == $this->excepted_result) &&
                ($this->servicemanager_data_insertservicecontentvalues == $this->excepted_result)
                ){
            header("Location: ".SITE_ROOT."zarzadzaj-uslugami.html");
        }
        else {
            header("Location: ".SITE_ROOT."zarzadzaj-uslugami.html");
        }
    }

}
